package com.qdxwx.manage.controller.channel;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.common.page.TableDataInfo;
import com.qdxwx.data.service.channel.ChannelService;
import com.qdxwx.common.annotation.Permissions;
import com.qdxwx.manage.controller.BaseController;
import com.qdxwx.models.channel.Channel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 频道设置Controller
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Controller
@RequestMapping("/channel")
public class ChannelController extends BaseController {
    @Autowired
    private ChannelService channelService;

    @GetMapping("/list.html")
    public String list() {
        return "channel/channel-list";
    }

    /**
     * 查询基本设置列表
     */
    @Permissions("channel:list")
    @PostMapping("/list.json")
    @ResponseBody
    public TableDataInfo list(HttpServletRequest request) {
        Channel channel = new Channel();
        List<Channel> list = channelService.getList(channel, PageRequest.form(request));
        long count = channelService.count(channel);
        return new TableDataInfo(list, count);
    }
}
